class FooMatcher{
    static [Symbol.match](target) {
        return target.includes('foo');
    };
};

console.log('foobar'.match(FooMatcher)); // true